From df517cb1d50d583d61ce3c5a45116298428d7bed Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 15 Jun 2005 19:25:49 +0000 Subject: [PATCH] Add two new settings, gtk-cursor-theme-name and gtk-cursor-theme-size to 2005-06-15 Matthias Clasen * gtk/gtksettings.c: Add two new settings, gtk-cursor-theme-name and gtk-cursor-theme-size to control the cursor theme. * gdk/x11/gdkevents-x11.c: Add two new X settings, Gtk/CursorThemeName and Gtk/CursorThemeSize, and map these to the gtk settings. * tests/testgtk.c (create_cursors): Add a cursor theme testcase. --- ChangeLog | 11 +++++++ ChangeLog.pre-2-10 | 11 +++++++ ChangeLog.pre-2-8 | 11 +++++++ gdk/x11/gdkevents-x11.c | 2 ++ gtk/gtksettings.c | 63 +++++++++++++++++++++++++++++++++++++---- tests/testgtk.c | 49 ++++++++++++++++++++++++++++++++ 6 files changed, 142 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9fd51f2302..63982fb9ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2005-06-15 Matthias Clasen + * gtk/gtksettings.c: Add two new settings, + gtk-cursor-theme-name and gtk-cursor-theme-size to + control the cursor theme. + + * gdk/x11/gdkevents-x11.c: Add two new X settings, + Gtk/CursorThemeName and Gtk/CursorThemeSize, and map + these to the gtk settings. + + * tests/testgtk.c (create_cursors): Add a cursor theme + testcase. + * gdk/x11/gdkwindow-x11.[hc]: Keep a reference to the GdkCursor and add a private getter for it, so that we can update the cursor when the cursor theme changes. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9fd51f2302..63982fb9ce 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,16 @@ 2005-06-15 Matthias Clasen + * gtk/gtksettings.c: Add two new settings, + gtk-cursor-theme-name and gtk-cursor-theme-size to + control the cursor theme. + + * gdk/x11/gdkevents-x11.c: Add two new X settings, + Gtk/CursorThemeName and Gtk/CursorThemeSize, and map + these to the gtk settings. + + * tests/testgtk.c (create_cursors): Add a cursor theme + testcase. + * gdk/x11/gdkwindow-x11.[hc]: Keep a reference to the GdkCursor and add a private getter for it, so that we can update the cursor when the cursor theme changes. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9fd51f2302..63982fb9ce 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,16 @@ 2005-06-15 Matthias Clasen + * gtk/gtksettings.c: Add two new settings, + gtk-cursor-theme-name and gtk-cursor-theme-size to + control the cursor theme. + + * gdk/x11/gdkevents-x11.c: Add two new X settings, + Gtk/CursorThemeName and Gtk/CursorThemeSize, and map + these to the gtk settings. + + * tests/testgtk.c (create_cursors): Add a cursor theme + testcase. + * gdk/x11/gdkwindow-x11.[hc]: Keep a reference to the GdkCursor and add a private getter for it, so that we can update the cursor when the cursor theme changes. diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c index 6897775d8b..97b027c870 100644 --- a/gdk/x11/gdkevents-x11.c +++ b/gdk/x11/gdkevents-x11.c @@ -2766,6 +2766,8 @@ static const struct { "Gtk/ButtonImages", "gtk-button-images" }, { "Gtk/MenuImages", "gtk-menu-images" }, { "Gtk/MenuBarAccel", "gtk-menu-bar-accel" }, + { "Gtk/CursorThemeName", "gtk-cursor-theme-name" }, + { "Gtk/CursorThemeSize", "gtk-cursor-theme-size" }, { "Xft/Antialias", "gtk-xft-antialias" }, { "Xft/Hinting", "gtk-xft-hinting" }, { "Xft/HintStyle", "gtk-xft-hintstyle" }, diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index dd00053e9c..9ac9a97f1f 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -25,6 +25,14 @@ #include "gtkprivate.h" #include "gtkalias.h" +#ifdef GDK_WINDOWING_X11 +#include "x11/gdkx.h" +#endif + +#if 0 +#include +#endif + typedef struct _GtkSettingsValuePrivate GtkSettingsValuePrivate; typedef enum @@ -46,11 +54,6 @@ struct _GtkSettingsPropertyValue GtkSettingsSource source; }; -#if 0 -#include -#include -#endif - enum { PROP_0, PROP_DOUBLE_CLICK_TIME, @@ -72,6 +75,8 @@ enum { PROP_XFT_HINTSTYLE, PROP_XFT_RGBA, PROP_XFT_DPI, + PROP_CURSOR_THEME_NAME, + PROP_CURSOR_THEME_SIZE, #endif PROP_ALTERNATIVE_BUTTON_ORDER }; @@ -97,6 +102,10 @@ static guint settings_install_property_parser (GtkSettingsClass *class, static void settings_update_double_click (GtkSettings *settings); static void settings_update_modules (GtkSettings *settings); +#ifdef GDK_WINDOWING_X11 +static void settings_update_cursor_theme (GtkSettings *settings); +#endif + /* --- variables --- */ @@ -136,6 +145,7 @@ gtk_settings_get_type (void) #if 0 static void + gtk_default_substitute (FcPattern *pattern, gpointer data) { @@ -427,6 +437,26 @@ gtk_settings_class_init (GtkSettingsClass *class) NULL); g_assert (result == PROP_XFT_DPI); + + result = settings_install_property_parser (class, + g_param_spec_string ("gtk-cursor-theme-name", + P_("Cursor theme name"), + P_("Name of the cursor theme to use"), + NULL, + GTK_PARAM_READWRITE), + NULL); + g_assert (result == PROP_CURSOR_THEME_NAME); + + result = settings_install_property_parser (class, + g_param_spec_int ("gtk-cursor-theme-size", + P_("Cursor theme size"), + P_("Size to use for cursors"), + 0, 128, 24, + GTK_PARAM_READWRITE), + NULL); + + g_assert (result == PROP_CURSOR_THEME_SIZE); + #endif /* GDK_WINDOWING_X11 */ result = settings_install_property_parser (class, g_param_spec_boolean ("gtk-alternative-button-order", @@ -630,6 +660,12 @@ gtk_settings_notify (GObject *object, */ gtk_rc_reset_styles (GTK_SETTINGS (object)); break; +#endif +#ifdef GDK_WINDOWING_X11 + case PROP_CURSOR_THEME_NAME: + case PROP_CURSOR_THEME_SIZE: + settings_update_cursor_theme (settings); + break; #endif /* GDK_WINDOWING_X11 */ } } @@ -1406,5 +1442,22 @@ settings_update_modules (GtkSettings *settings) g_free (modules); } +#ifdef GDK_WINDOWING_X11 +static void +settings_update_cursor_theme (GtkSettings *settings) +{ + GdkDisplay *display = gdk_screen_get_display (settings->screen); + gchar *theme = NULL; + gint size = 0; + + g_object_get (settings, + "gtk-cursor-theme-name", &theme, + "gtk-cursor-theme-size", &size, + NULL); + + gdk_x11_display_set_cursor_theme (display, theme, size); +} +#endif + #define __GTK_SETTINGS_C__ #include "gtkaliasdef.c" diff --git a/tests/testgtk.c b/tests/testgtk.c index a731b7270d..0b967d87b9 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -5890,6 +5890,30 @@ cursor_event (GtkWidget *widget, return FALSE; } +#ifdef GDK_WINDOWING_X11 +#include "x11/gdkx.h" + +static void +change_cursor_theme (GtkWidget *widget, + gpointer data) +{ + const gchar *theme; + gint size; + GList *children; + + children = gtk_container_get_children (GTK_CONTAINER (data)); + + theme = gtk_entry_get_text (GTK_ENTRY (children->next->data)); + size = (gint) gtk_spin_button_get_value (GTK_SPIN_BUTTON (children->next->next->data)); + + g_list_free (children); + + gdk_x11_display_set_cursor_theme (gtk_widget_get_display (widget), + theme, size); +} +#endif + + static void create_cursors (GtkWidget *widget) { @@ -5904,6 +5928,8 @@ create_cursors (GtkWidget *widget) GtkWidget *label; GtkWidget *any; GtkAdjustment *adj; + GtkWidget *entry; + GtkWidget *size; if (!window) { @@ -5930,10 +5956,33 @@ create_cursors (GtkWidget *widget) "GtkWidget::visible", TRUE, NULL); +#ifdef GDK_WINDOWING_X11 hbox = gtk_hbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); + + label = gtk_label_new ("Cursor Theme : "); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); + + entry = gtk_entry_new (); + gtk_entry_set_text (GTK_ENTRY (entry), "default"); + gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, TRUE, 0); + + size = gtk_spin_button_new_with_range (1.0, 64.0, 1.0); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (size), 24.0); + gtk_box_pack_start (GTK_BOX (hbox), size, TRUE, TRUE, 0); + g_signal_connect (entry, "changed", + G_CALLBACK (change_cursor_theme), hbox); + g_signal_connect (size, "changed", + G_CALLBACK (change_cursor_theme), hbox); +#endif + + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); + label = gtk_label_new ("Cursor Value : "); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); -- 2.30.2